package com.liang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liang.entity.CKaoshi;
import com.liang.mapper.CKaoshiMapper;
import com.liang.service.CKaoshiService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 李昂
 * @since 2020-11-30
 */
@Service
@AllArgsConstructor
public class CKaoshiServiceImpl extends ServiceImpl<CKaoshiMapper, CKaoshi> implements CKaoshiService {

    private CKaoshiMapper kaoshiMapper;

    /**
     * @Author 李昂
     * @Description 批量插入考试成绩
     * @Date 2020/12/4 15:35
     */
    @Override
    public boolean insertScores(List<CKaoshi> kaoshis) {
        return this.saveBatch(kaoshis);
    }

    /**
     * @Author 李昂
     * @Description 根据title子段进行分组 显示考试类型
     * @Date 2020/12/4 15:53
     */
    @Override
    public List<CKaoshi> showAllKaoshi(String title) {
        return kaoshiMapper.showAllKaoshi(title);
    }

    /**
     * @Author 李昂
     * @Description 显示本次考试成员的成绩
     * @Date 2020/12/4 15:53
     */
    @Override
    public List<CKaoshi> showScore(String title) {
        return this.baseMapper.showScore(title);
    }

    /**
     * @Author 李昂
     * @Description 删除某一次考试的所有成绩
     * @Date 2020/12/4 17:49
     */
    @Override
    public boolean deleteKaoshi(String title) {
        LambdaQueryWrapper<CKaoshi> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(CKaoshi::getTitle, title);
        return this.remove(lambdaQueryWrapper);
    }



    //根据学号查询个人考试成绩
    @Override
    public List<CKaoshi> getGradeBySno(String sno) {
        return this.baseMapper.getGradeBySno(sno);
    }


    @Override
    //获取考试成绩 平均分  最高分  最低分
    public List<CKaoshi> GroupKaoshi() {
        return this.baseMapper.GroupKaoshi();
    }




}
